/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.offmessage.controller
 * FILE    NAME: OffMessageDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.jodinfo.outmirror.entity.OffMessageEntity;
import com.jodinfo.outmirror.service.OffMessageBizService;
import com.jodinfo.outmirror.util.ResponseEntity;
import com.jodinfo.outmirror.util.SysConstant;



@Controller
@RequestMapping(value = "/OffMessageAdmin")
public class OffMessageController  {
	
@Resource(name="offMessageBizService")
private OffMessageBizService offMessageBizService;
/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String OffMessageList(OffMessageEntity offMessageEntity) {
	if(offMessageEntity==null){
		offMessageEntity = new OffMessageEntity();
		offMessageEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		offMessageEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	String str = offMessageBizService.queryListForPageOffMessage(offMessageEntity);
	return str;
}
/**
* OffMessageEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView offMessageListPage(OffMessageEntity offMessageEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("offMessageList"));
}
/**
* OffMessageEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView offMessageEditPage(OffMessageEntity offMessageEntity) {
	
	return new ModelAndView(returnPath("offMessageAdd"));
}
/**
 * 查询OffMessageEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findOffMessageData(HttpServletRequest request) {
	String id = request.getParameter("id");
	OffMessageEntity offMessageEntity =  offMessageBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(offMessageEntity); 
}

/**
 * 保存或更新OffMessage 
 * 
 **/
@RequestMapping(value = "/saveOffMessage")
public @ResponseBody String saveOffMessageData(OffMessageEntity offMessageEntity) {
	ResponseEntity rs = null;
	if(offMessageEntity!=null){
		if(offMessageEntity.getId()!=null){
			rs = offMessageBizService.updateOffMessage(offMessageEntity);
		}else{
			rs = offMessageBizService.addOffMessage(offMessageEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出OffMessageEntity
 * @author ZhangYuanYuan
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportOffMessageExcel")
public void exportOffMessageExcel(OffMessageEntity offMessageEntity,HttpServletResponse response) {
		offMessageBizService.exportOffMessage(offMessageEntity, response);
}
/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/offmessage/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
